import { requestCategoryList, requestBannerList, requestFloorList } from '@/api/index'


export default {
  namespaced: true,
  actions: {
    // 获取三级分类数据
    async getCategoryList(context) {
      let result = await requestCategoryList()
      if (result.code === 200) {
        context.commit('GETCATEGORYLIST', result.data)
      }
    },
    // 获取banner轮播图图片数据
    async getBannerList(context) {
      let result = await requestBannerList()
      if (result.code === 200) {
        context.commit('REQUESTBANNERLIST', result.data)
      }
    },
    // 获取floor轮播图图片数据
    async getFloorList(context) {
      let result = await requestFloorList()
      if (result.code === 200) {
        context.commit('GETFLOORLIST', result.data)
      }
    }
  },
  mutations: {
    GETCATEGORYLIST(state, val) {
      state.categoryList = val
    },
    REQUESTBANNERLIST(state, val) {
      state.bannerList = val
    },
    GETFLOORLIST(state, val) {
      state.floorList = val
    }
  },
  state: {
    categoryList: [],
    bannerList: [],
    floorList: []
  },
  getters: {}
}